/**
 * 
 * @authors Bmeria (67403428@qq.com)
 * @date    2017-07-18 16:34:15
 */








$(function() {
    // 如果不支持placeholder，用jQuery来完成
    if (!isSupportPlaceholder()) {
        // 遍历所有input对象, 除了密码框
        $('input').not("input[type='password']").each(
            function() {
                var self = $(this);
                var val = self.attr("placeholder");
                input(self, val);
            }
        );

    }
});

// 判断浏览器是否支持placeholder属性
function isSupportPlaceholder() {
    var input = document.createElement('input');
    return 'placeholder' in input;
}

// jQuery替换placeholder的处理
function input(obj, val) {
    var $input = obj;
    var val = val;
    $input.attr({ value: val });
    $input.focus(function() {
        if ($input.val() == val) {
            $(this).attr({ value: "" });
        }
    }).blur(function() {
        if ($input.val() == "") {
            $(this).attr({ value: val });
        }
    });
}


$(document).ready(function() {
    $('#fullpage').fullpage({
        anchors: ['firstpage', 'secondpage', '3rdpage', '4thpage', '5thpage', '6thpage', '7thpage', '8thpage', '9thpage'],
        menu: '#menu',
        // navigation: true,
        // navigationPosition: 'right',
        // navigationTooltips: ['First page', 'Second page', 'Third and last page'],
        autoScrolling: false,
        fitToSection: false,
        lockAnchors: true,

        afterLoad: function(anchorLink, index) {
            if (index == 1) {
                $('.topbar').removeClass('blackbg');
                $('.right-bar4').hide();
            }
            else{
                $('.right-bar4').show();
            }
        },

        onLeave: function(index, nextIndex, direction) {
            var leavingSection = $(this);

            //after leaving section 2
            if (index == 3) {

                $('#section2').find('.intro').delay(500).animate({
                    left: '-130%'
                }, 1500, 'easeOutExpo');


            }
        }
    });

});

// 右侧栏
// 
$(document).on('click', '#go-top', function() {
   $.fn.fullpage.moveTo('firstpage', 1);
});




// 滚动导航跟随
$(window).scroll(function() {
    var height = $(window).scrollTop();
    var iWinWidth = $(window).width();
    if ((height > 40) & (iWinWidth > 768)) {
        $('.topbar').addClass("blackbg");
    }

    if (height < 100) {
        $(".topbar").removeClass("blackbg");
    }

});





// 刷新置顶

window.onload=function(){
   setTimeout(() => window.scrollTo(0,0),150)
}

$(document).ready(function() {
     if (($(window).width() > 768)) {
    $(".jt-box").removeClass('fadeInDown');
    $(".jt-box").addClass('fadeInLeft');
    }
    if(($(window).width() < 768)) {
    $(".jt-box").removeClass('fadeInLeft');
    $(".jt-box").addClass('fadeInDown');
    }
});

$(document).on('click', '#page1', function() {
    $.fn.fullpage.moveTo('firstpage', 1);
});
$(document).on('click', '#page2', function() {
    $.fn.fullpage.moveTo('secondpage', 1);
});
$(document).on('click', '#page3', function() {
    $.fn.fullpage.moveTo('3rdpage', 1);
});
$(document).on('click', '#page4', function() {
    $.fn.fullpage.moveTo('4thpage', 1);
});
$(document).on('click', '#page5', function() {
    $.fn.fullpage.moveTo('5thpage', 1);
});
$(document).on('click', '#page6', function() {
    $.fn.fullpage.moveTo('6thpage', 1);
});
$(document).on('click', '#page7', function() {
    $.fn.fullpage.moveTo('7thpage', 1);
});
$(document).on('click', '#page8', function() {
    $.fn.fullpage.moveTo('8thpage', 1);
});
$(document).on('click', '#page9', function() {
    $.fn.fullpage.moveTo('9thpage', 1);
});

  $(document).ready(function() {
      $(".headline-bg").height($(window).height());
  });
  $(window).resize(function() {
      $(".headline-bg").height($(window).height());
  });


// 手机版菜单
$(document).on('click', '#slide-bt', function() {
    var nav = "<i class='icon icon-align-justify'>" + "</i>"
    $("header").css({'left': '0%'},500);
    $(this).html(nav);
    $(this).addClass('active');
});

$(document).on('click', '.btn.active', function() {
    var nav2 = "<i class='icon icon-list-ul'>" + "</i>"
    $("header").css({'left': '-25%;'},500);
    $(this).removeClass('active');
    $(this).html(nav2);
});